package com.simpleframe.validator.validators;

import com.simpleframe.validator.FieldValidator;

public class MinlengthValidator extends FieldValidator {

	@Override
	public void validate(Object object) {
		System.out.println("验证最小长度");
		String fieldName= getFieldName();
		String fieldValue = getFieldValue();
		
		int length = 0;
		try {
			length = Integer.parseInt(getValue());
		} catch (Exception e) {}
		
		if(fieldValue !=null && fieldValue.length() > 0 && fieldValue.trim().length() > 0){
			if(fieldValue.trim().length() < length){
				addFieldError(fieldName, label+"的长度不能小于"+length+"，当前长度为"+fieldValue.trim().length());
			}
		}
		
	}
	
	@Override
	public String getMessage() {
		// TODO Auto-generated method stub
		return null;
	}

}
